#!/usr/bin/env bash
#
# Copyright 2019 Apex.AI, Inc.
# SPDX-License-Identifier: Apache-2.0

set -xe

cd "$(dirname "$(realpath "$0")")"

VSCODE_VERSION="$1"; shift

# Download and install VSCode
curl -L "https://update.code.visualstudio.com/${VSCODE_VERSION}/linux-x64/stable" -o "vscode-${VSCODE_VERSION}.tar.gz"
tar xfz "vscode-${VSCODE_VERSION}.tar.gz"
mv VSCode-linux-x64 _opt_vscode
chown root:root _opt_vscode -R

# Environment Setup
cp env.sh _opt_vscode/.env.sh

# Use _opt_atom for readability, rename to _opt b/c it's expected by Dockerfile
mv _opt_vscode _opt
